package demo1;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: liangyuanzhang
 * Date: 2025-3-09
 * Time: 18:45
 */
public class Test {
    // str:"BAabB"
    public static String func(String str){
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            char ch = str.charAt(i);
            // == -1 代表没有找到当前字符串
            if (stringBuilder.indexOf(ch+"") == -1){
                stringBuilder.append(ch);
            }
        }
        return stringBuilder.toString();
    }
    public static void merge(int[] A,int m,int[] B,int n){
        int i = m -1;
        int j = n - 1;
        int k = (m+n)-1;
        while (i >= 0 && j >= 0){
            if (A[i] > B[j]){
                A[k] = A[i];
                k--;
                i--;
            }else {
                A[k] = B[j];
                k--;
                j--;
            }
        }
        while (i >= 0){
            A[k] = A[i];
            k--;
            i--;
        }
        while (j >= 0){
            A[k] = B[j];
            k--;
            j--;
        }
    }
    public static void main(String[] args) {
        int[] A = {1,2,3,0,0,0};
        int[] B = {4,5,6};
        merge(A,3,B,3);
        System.out.println(Arrays.toString(A));
    }
    public static void main1(String[] args) {
        System.out.println(func("BAabB"));//BAab
    }
}
